package cn.edu.nhic.nhcarsb.controller;

import cn.edu.nhic.nhcarsb.entity.Category;
import cn.edu.nhic.nhcarsb.entity.R;
import cn.edu.nhic.nhcarsb.service.CategoryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/category")
public class CategoryController extends BaseController{
    @Autowired
    private CategoryService categoryService;
    @GetMapping("/{pno}/{psize}")
    public R List(@PathVariable int pno,@PathVariable int psize){
        Page<Category> page = new Page<>(pno, psize);
        QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("cid");
        Page<Category> categoryPage = categoryService.page(page, queryWrapper);
        return R.success(categoryPage);
    }
}
